<!DOCTYPE html>
<html lang="en">

<head>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">

    <title>监控中心 - 用户管理</title>

    <!-- Bootstrap Core CSS -->
    <link href="${request.getContextPath()}/public/vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">

    <!-- MetisMenu CSS -->
    <link href="${request.getContextPath()}/public/vendor/metisMenu/metisMenu.min.css" rel="stylesheet">

    <!-- Custom CSS -->
    <link href="${request.getContextPath()}/public/dist/css/sb-admin-2.css" rel="stylesheet">

    <!-- Custom Fonts -->
    <link href="${request.getContextPath()}/public/vendor/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">

    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
        <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
        <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->

</head>

<body>

    <div id="wrapper">

        <!--嵌入头部跟菜单-->
        <#include "/admin/inc/menu.html"/>

        <!-- Page Content -->
        <div id="page-wrapper">
            <div class="container-fluid">

                <div class="row">
                    <div class="col-lg-10">
                        <h4 class="page-header">关联仓单 —— 当前用户：${user.account}</h4>
                    </div>
                </div>
        <!-- /.row -->
        <div class="row">

            <div class="col-lg-12">

                <div class="panel-body">
                    <div class="table-responsive">
                        <table class="table table-striped table-bordered table-hover">
                            <thead>
                                <tr>
                                    <th><input type="checkbox" onclick="choiseAll(this);"/></th>
                                    <th>仓单编号</th>
                                    <th>仓库名称</th>
                                    <th>入库日期</th>
                                    <th>货主名称</th>
                                    <th>品种</th>
                                    <th>属性</th>
                                    <th>总重量</th>
                                    <th>总数量</th>
                                </tr>
                            </thead>
                            <tbody>
                                <#if receipts??>
                                    <#list receipts as rep>
                                    <tr>
                                        <td><input class="input-checkbox" value="${rep.no}" type="checkbox" <#if userRepNos?seq_contains(rep.no)>checked="checked"</#if> /> </td>
                                        <td>${rep.no}</td>
                                        <td>${rep.warehouse.name}</td>
                                        <td>${rep.joinTime?string("yyyy-MM-dd")}</td>
                                        <td>${rep.ownerName}</td>
                                        <td>${rep.breed}</td>
                                        <td>${rep.attribute}</td>
                                        <td>${rep.goodsWeight} <#if rep.weightType==0>吨<#else>公斤</#if> </td>
                                        <td>${rep.goodsQuantity} <#if rep.quantityType==0>捆<#else>包</#if></td>

                                    </tr>
                                    </#list>
                                </#if>

                            </tbody>
                        </table>

                        <button class="btn btn-primary" onclick="choiseRep();">确定</button>
                        <a href="${request.getContextPath()}/admin/user/list.do" class="btn btn-default">返回</a>
                    </div>
                    <!-- /.table-responsive -->
                </div>

            </div>

        </div>
        <!-- /.row -->
                
                <!-- /.row -->
            </div>
            <!-- /.container-fluid -->
        </div>
        <!-- /#page-wrapper -->

    </div>
    <!-- /#wrapper -->



    <!-- jQuery -->
    <script src="${request.getContextPath()}/public/vendor/jquery/jquery.min.js"></script>

    <!-- Bootstrap Core JavaScript -->
    <script src="${request.getContextPath()}/public/vendor/bootstrap/js/bootstrap.min.js"></script>

    <!-- Metis Menu Plugin JavaScript -->
    <script src="${request.getContextPath()}/public/vendor/metisMenu/metisMenu.min.js"></script>

    <!-- Custom Theme JavaScript -->
    <script src="${request.getContextPath()}/public/dist/js/sb-admin-2.js"></script>


    <script>

        //全选 反选
        function choiseAll(dom){

            var boxs = $(".input-checkbox");

            for(var i=0;i<boxs.length;i++){

                boxs[i].checked = dom.checked;
            }

        }


        //确认分配的仓单
        function choiseRep(){

            var nos ="";

            var boxs = $(".input-checkbox");

            for(var i=0;i<boxs.length;i++){

                if(boxs[i].checked){

                    nos+="\""+boxs[i].value+"\",";
                }
            }

            if(nos!="") nos = nos.substr(0,nos.length-1);

            var str ="{\"userId\":${user.id},\"repNo\":["+nos+"]}";

            console.info(str);

            //提交数据
            var url="${request.getContextPath()}/admin/user/subChoiseRep.do";

            $.post(url,{jsonStr:str},function(data){

                alert(data.msg);

                location.href="${request.getContextPath()}/admin/user/list.do";

            },"json");

        }


    </script>


</body>

</html>
